/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openjawtech.xscraper.web.action;

import com.opensymphony.xwork2.ActionSupport;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.openjawtech.xscraper.web.service.AirportsService;
import com.openjawtech.xscraper.web.util.WebUtil;

/**
 *
 * @Created on 17-Mar-2009, 00:47:15
 * @author Wenbo.Sun
 */
public class GetAllAirportsAction extends ActionSupport {
    private static final long serialVersionUID = 1L;
    private List<String> departures;

    @Autowired
    private AirportsService airportsService;

    public List<String> getDepartures() {
        return departures;
    }

    public void setDepartures(List<String> departures) {
        this.departures = departures;
    }

    @Override
    public String execute() throws Exception {
        List<String> list = (List<String>)WebUtil.getFromSession(WebUtil.DEPARTURES);
        if(list == null){
            list = airportsService.getAllDepartures();
            WebUtil.addToSession(WebUtil.DEPARTURES, list);
        }
        departures = list;
        return SUCCESS;
    }


}
